﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MashGen.Engine.Expressions
{
    public class Quotient : AbstractExpression
    {
        public AbstractExpression Numerator { get; private set; }
        public AbstractExpression Denominator { get; private set; }

        public Quotient(AbstractExpression numerator, AbstractExpression denominator)
        {
            if (numerator == null)
            {
                throw new ArgumentNullException("numerator");
            }
            if (denominator == null)
            {
                throw new ArgumentNullException("denominator");
            }
            Numerator = numerator;
            Denominator = denominator;
        }

        public override R Vist<R, P>(IExpressionVisitor<R, P> visitor, P parameter = default(P))
        {
            return visitor.VisitQuotient(this, parameter);
        }

        public override bool Equals(AbstractExpression other)
        {
            var otherQuotient = other as Quotient;
            if (ReferenceEquals(otherQuotient, null))
            {
                return false;
            }
            return Numerator.Equals(otherQuotient.Numerator) 
                && Denominator.Equals(otherQuotient.Denominator);
        }

        public override int GetHashCode()
        {
            return 7 * Numerator.GetHashCode() + Denominator.GetHashCode();
        }
    }
}
